Link | regexp->forEachMatch |
Author | Brad Lindsay |
Category | String |
Version | 9.x |
License | Public Domain |
Posted | 06 Aug 2012 |
Updated | 06 Aug 2012 |
More by this author... |
The [regexp->forEachMatch] method allows you to iterate over each match in your regular expression to do complex replacements. It also automatically calls the [regexp->appendTail] at the end that is easy to forget.
local(matcher) = regexp(-find=`(?i)[aeiou]`, -input='Whoa, this is heavy!') #matcher->forEachMatch => { #1->appendReplacement(string_upperCase(#1->matchString(0))) } #matcher->output // Outputs: WhOA, thIs Is hEAvy! local(no_vowels) = regexp(-find=`(?i)[aeiou]`, -input='Lager, sir, is regal')->forEachMatch => { #1->appendReplacement('_') }&output // #no_vowels no the following string: 'L_g_r, s_r, _s r_g_l'
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define regexp->forEachMatch => { while(.find) => { givenBlock(self) } .appendTail }
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft